1. Field of the Invention
The present invention relates to the field of three-dimensional (3D) computer graphics, and in particular to the use of texture maps and lightmaps to render an image of a 3D computer model.
2. Related Background Art
The use of texture maps and lightmaps is widely known in the field of three-dimensional computer graphics.
In texture mapping, a two-dimensional (2D) image is mapped onto a surface primitive representing part of an object to generate visible surface pattern detail on the surface. The image to be mapped onto the surface is called a texture map, and its individual elements are called texels, each having a plurality of colour component values defining an image value. The use of texture mapping allows surface detail to be represented in high resolution without using a large number of polygons or other geometric primitives to model the detail.
A single texture map is often repeatedly mapped onto many surface primitives. For example, a texture map comprising an image of a brick may be repeatedly mapped onto different surface primitives representing one or more walls. However, the lighting may vary from wall to wall or over different parts of the same wall depending upon the positions of the light sources.
Lightmapping offers a solution to this problem. A lightmap is an image comprising a 2D array of “lumels”, each comprising a plurality of colour component values defining an illumination value representing the intensity of the light at that location on a surface primitive, and the lightmap is applied to a surface primitive together with the texture map. Thus, each surface primitive is rendered with two textures—one representing the surface pattern and one representing the illumination, to give a realistic looking primitive in the image.
In order to generate a 3D computer model at acceptable real-time frame rates (that is 25 or 30 frames per second) using texture mapping and lightmapping, it is currently necessary to use hardware to accelerate the processing.
The hardware processing capabilities determine how a texture map and a lightmap are applied to a surface primitive.
More particularly, if the hardware supports vector-modulating multiplication to the frame buffer during rendering (such that R1, G1, B1 multiplied by R2, G2, B2 is R1×R2, G1×G2, B1×B2—where R, G and B represent red, green and blue values respectively for a pixel) then a first pass is performed to render the texture map onto the surface polygon in the frame buffer followed by a second pass in which the pixel values resulting from the first pass are modulated with the lightmap values in accordance with vector-modulating multiplication.
However, not all hardware platforms support vector-modulating multiplication to the frame buffer; some only support vector subtraction and scalar multiplication. In this case, the lightmap is inverted (to give what is known as a “darkmap”) and the inverted lightmap (darkmap) is subtracted from the rendered texture map values in the frame buffer, for example as suggested in the article “Lightmapping” at http://www.delphi3d.net/articles/printarticle.php?article=lightmapping.htm.
One problem, however, with the subtraction of darkmaps from textured images is that the resulting images often have undesirable visual properties, a particular one being that they may appear very dark.